package cn.itsource.service.impl;

import cn.itsource.pojo.domain.DriverSetting;
import cn.itsource.mapper.DriverSettingMapper;
import cn.itsource.pojo.properties.DriverSettingProPerties;
import cn.itsource.service.IDriverSettingService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * <p>
 * 司机配置 服务实现类
 * </p>
 *
 * @author ????
 * @since 2024-06-13
 */
@Service
public class DriverSettingServiceImpl extends ServiceImpl<DriverSettingMapper, DriverSetting> implements IDriverSettingService {
    //创建配置对象
    @Autowired
    private DriverSettingProPerties settingProPerties;
    @Override
    public void createSetting(Long id) {
        //保存一个driverSeting
        DriverSetting driverSetting = new DriverSetting();
        driverSetting.setId(id);
        driverSetting.setCreateTime(new Date());
        driverSetting.setListenService(true);
        driverSetting.setAutoAccept(true);
        driverSetting.setOrientation(true);
        //订单超过50公里不接//TODO
        driverSetting.setOrderDistance(settingProPerties.getOrderDistance());
        driverSetting.setRangeDistance(settingProPerties.getRangeDistance());

        //保存配置对象
        this.save(driverSetting);
    }
}
